//
//  FTDefine.h
//  FTDefineKit
//
//  Created by docker on 2018/7/23.
//  Copyright © 2018年 498027547@qq.com. All rights reserved.
//

#ifndef FTDefine_h
#define FTDefine_h


#endif /* FTDefine_h */

/*！此方法为了控制台打印完整数据 */
#ifdef DEBUG
#define NSLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
#else
#define NSLog(format, ...)
#endif



// 通过16进制数设置颜色
#define kUIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue &0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
//应用程序的屏幕高度
#define KScreenHeiht               (KDevice_Is_iPhoneX?([[UIScreen mainScreen] bounds].size.height-34):[[UIScreen mainScreen] bounds].size.height)
//应用程序的屏幕宽度
#define KScreenWidth                [UIScreen mainScreen].bounds.size.width
//判断是否为iphone x
#define KDevice_Is_iPhoneX   ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

//宏定义检测block是否可用
#define BLOCK_EXEC(block, ...) if (block) { block(__VA_ARGS__); };





// 颜色设置
#define KBalckColor            kUIColorFromRGB(0x333333)
#define KBrownishGreyColor     kUIColorFromRGB(0x666666)
#define KGrayishGrayColor      kUIColorFromRGB(0x999999)
#define KInputColor            kUIColorFromRGB(0xcccccc)
#define KGaryColor             kUIColorFromRGB(0xeeeeee)
#define kBackgroundColor       kUIColorFromRGB(0xf7f8f8)
#define KWhiteColor            kUIColorFromRGB(0xffffff)


#define KStartColor            kUIColorFromRGB(0xff943f)

#define KEndColor              kUIColorFromRGB(0xff5f57)


#define KMainTopColor          kUIColorFromRGB(0xff4a43)
#define KMainColor             kUIColorFromRGB(0xff7100)

#define KMainTextColor         kUIColorFromRGB(0xff9430)

#define KZhangColor            kUIColorFromRGB(0xff4a43)
#define KDieColor              kUIColorFromRGB(0x35af21)
#define KDarkSkyBlueColor      kUIColorFromRGB(0x3a93d8)
#define KDarkSkyOrengerColor   kUIColorFromRGB(0xfda63c)
#define KSyOrengerColor        kUIColorFromRGB(0xff9719)
#define KGrayOrengerColor      kUIColorFromRGB(0xfff0de)


// margin define
#define KDefaultMarginLeft                   15 * KWidth_Scale
#define KDefaultMarginRight                  15 * KWidth_Scale
#define KDefaultTableViewFooterHigth         10 * KWidth_Scale
#define KDefaultTableViewHeaderHigth         56
#define KDefultTableViewZeroHigth            0.0001
#define KDefualtTableBarHigth                49
#define KNavigationBarHigth                  (KDevice_Is_iPhoneX?88:64)
#define KNavigationStateBarHigth             (KDevice_Is_iPhoneX?44:20)
#define KNavigationTitleBarHigth             44



// 保持适配的一致性
#define KWidth_Scale                         KScreenWidth/375.0
#define KFont(font)                          [UIFont systemFontOfSize:(font * KWidth_Scale)]
#define KBoldFont(font)                      [UIFont boldSystemFontOfSize:(font * KWidth_Scale)]



// iphonex UItableView 莫名向下偏移的问题

#define  adjustsScrollViewInsets(scrollView)\
do {\
_Pragma("clang diagnostic push")\
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"")\
if ([scrollView respondsToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
NSMethodSignature *signature = [UIScrollView instanceMethodSignatureForSelector:@selector(setContentInsetAdjustmentBehavior:)];\
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];\
NSInteger argument = 2;\
invocation.target = scrollView;\
invocation.selector = @selector(setContentInsetAdjustmentBehavior:);\
[invocation setArgument:&argument atIndex:2];\
[invocation retainArguments];\
[invocation invoke];\
}\
_Pragma("clang diagnostic pop")\
} while (0)




typedef void(^SuccessResultBlock)(id response);

typedef void(^FailureResultBlock)(id error);
